package com.ychen.springbatch.skip;

import org.springframework.batch.item.ItemProcessor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

/**
 * @author chenyuliao
 * @version 1.0
 * @description
 * @date 2020/10/21 13:12
 */
@Component
public class FirstNameUpperProcessor implements ItemProcessor<Customer, Customer> {
    @Override
    public Customer process(Customer item) throws Exception {
        Customer cus = new Customer();
        BeanUtils.copyProperties(item, cus);
        if ("1".equals(cus.getId())) {
            throw new CustomException("1", "异常");
        }
        cus.setFirstName(item.getFirstName().toUpperCase());
        return cus;
    }
}
